package com.mq.rabbitmq.topic.demo1;

import com.mq.rabbitmq.point.AmqpConfig;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * Created by Administrator on 2017/8/11.
 */
//@Configuration
@ConditionalOnBean(value = {AmqpConfig.class})
@EnableRabbit
@Import(value = {TopicSend.class})
public class TopicConfig {
    public static final String EXCHANGE   = "spring-topic-exchange";
    public static final String ROUTINGKEY1 = "weather-routingKey";

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(EXCHANGE);
    }

    @Bean
    public Queue queue() {
        return new Queue(ROUTINGKEY1,true); //队列持久
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(topicExchange()).with("test");
    }


}
